package protostuff;

import theobj.BlackCat;

import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        /*Student stu1 = new Student("张三", 20);
        Student stu2 = new Student("李四", 21);
        List<Student> students = new ArrayList<Student>();
        students.add(stu1);
        students.add(stu2);
        School school = new School("西工大", students);
        //首先是序列化
        byte[] bytes = ProtostuffUtils.serialize(school);
        System.out.println("序列化后: " + bytes.length);
        //然后是反序列化
        School group1 = ProtostuffUtils.deserialize(bytes, School.class);
        System.out.println("反序列化后: " + school.toString());*/
        showMeTimeAndSize();
    }

    public static void showMeTimeAndSize() {
        BlackCat black = new BlackCat("black", "我是黑猫");
        byte[] bytes = ProtostuffUtils.serialize(black);
        System.out.println("protostuff 大小: " + bytes.length);

//        BlackCat black = new BlackCat("black", "我是黑猫");
        long start = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
//            ProtostuffUtils.serialize(black);
            ProtostuffUtils.serialize(new BlackCat("black", "我是黑猫"));
        }
        System.out.println("protostuff 耗时: " + (System.currentTimeMillis() - start));

    }
}
